package com.unity3d.player;

import java.util.*;
import java.lang.reflect.*;

final class l
{
    private HashMap a;
    private Class b;
    private Object c;

    public l(final Class b, final Object c) {
        this.a = new HashMap();
        this.b = null;
        this.c = null;
        this.b = b;
        this.c = c;
    }

    private void a(final String s, final a a) {
        try {
            a.b = this.b.getMethod(s, (Class[])a.a);
        }
        catch (Exception ex) {
            final StringBuilder sb = new StringBuilder("Exception while trying to get method ");
            sb.append(s);
            sb.append(". ");
            sb.append(ex.getLocalizedMessage());
            e.Log(6, sb.toString());
            a.b = null;
        }
    }

    public final Object a(String s, final Object... array) {
        StringBuilder sb;
        if (!this.a.containsKey(s)) {
            sb = new StringBuilder("No definition for method ");
            sb.append(s);
            s = " can be found";
        }
        else {
            final a a = this.a.get(s);
            if (a.b == null) {
                this.a(s, a);
            }
            if (a.b == null) {
                sb = new StringBuilder("Unable to create method: ");
            }
            else {
                try {
                    if (array.length == 0) {
                        return a.b.invoke(this.c, new Object[0]);
                    }
                    return a.b.invoke(this.c, array);
                }
                catch (Exception ex) {
                    final StringBuilder sb2 = new StringBuilder("Error trying to call delegated method ");
                    sb2.append(s);
                    sb2.append(". ");
                    sb2.append(ex.getLocalizedMessage());
                    e.Log(6, sb2.toString());
                    return null;
                }
            }
        }
        sb.append(s);
        e.Log(6, sb.toString());
        return null;
    }

    public final void a(final String s, final Class[] array) {
        this.a.put(s, new a(array));
    }

    final class a
    {
        public Class[] a;
        public Method b;

        public a(final Class[] a) {
            this.a = a;
            this.b = null;
        }
    }
}
